# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from typing import Dict, Union
from pydantic import BaseModel, Field


class SpeechConfig(BaseModel):
    """ 语音配置参数 """
    open: int = Field(default=0, ge=0, le=1, description="渠道开关")
    name: str = Field(max_length=100, description="渠道名称")
    model: str = Field(max_length=100, description="模型名称")
    voice: str = Field(max_length=100, description="发音人")
    speed: int = Field(ge=0, le=100, description="发音语速")
    volume: int = Field(ge=0, le=100, description="音量大小")
    agency_api: str = Field(max_length=1800, default="", description="代理地址")
    models: Dict[str, str] = Field(description="模型列表")
    pronounces: Dict[str, str] = Field(description="发音人列表")


class TransferConfig(BaseModel):
    """ 语音配置参数 """
    name: str = Field(max_length=100, description="渠道名称")
    model: str = Field(max_length=100, description="模型名称")
    agency_api: str = Field(default="", max_length=1800, description="代理地址")
    models: Dict[str, str] = Field(description="模型列表")


class VoiceChannel(BaseModel):
    """ 语音渠道参数 """
    is_open: int = Field(ge=0, le=1, description="渠道开关")
    channel: str = Field(pattern=r"^(browser|xunfei|qwen|openai)$", description="渠道通道")
    configs: Dict[str, Union[SpeechConfig, TransferConfig]] = Field(description="配置参数")


class VoiceConfigVo(BaseModel):
    """ 语音配置Vo """
    speech: VoiceChannel = Field(description="文本转语音配置")
    transfer: VoiceChannel = Field(description="语音转文本配置")

    class Config:
        json_schema_extra = {
            "example": {

            }
        }
